package com.futurelight.recipes.dao;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;

@Database(entities = {EntityResult.class,EntityFavorite.class}, version = 1, exportSchema = false)
@TypeConverters({ResultsConvert.class})
public abstract class RecipesDatabase extends RoomDatabase {
    public abstract RecipesDao getDao();

    private static RecipesDatabase instance;

    public static RecipesDatabase getInstance(Context context) {
        if (instance == null) {
            synchronized (RecipesDatabase.class) {
                if (instance == null) {
                    instance = Room.databaseBuilder(context, RecipesDatabase.class, "recipes.db")
                            .build();
                }
            }
        }
        return instance;
    }

}